import {createStore, combineReducers, applyMiddleware} from 'redux';
import middleWare from './myMiddleWare';
// import middleWare2 from './myMiddleWare2'
// import thunk from 'redux-thunk';
import * as types from './actions';

const user = (state = {
  name: 'zhouyang',
  age: 18
}, action) => {
  switch (action.type) {
    case types.MOD_AGE:
      return {
        ...state,
        age: action.value
      };
    case types.ADD_AGE:
      return {
        ...state,
        age: Number(state.age) + 1
      };
    default:
      return state;
  }
}

export default createStore(combineReducers({user}), applyMiddleware(middleWare));